﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace EXAM.Admin.Page_Admin.UsrControl
{
    public partial class ucSetValueFilter : System.Web.UI.UserControl
    {
        private object _dataItem = null;

        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        ///        Required method for Designer support - do not modify
        ///        the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.DataBinding += new System.EventHandler(this.EmployeeDetails_DataBinding);

        }
        #endregion

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }

        protected void EmployeeDetails_DataBinding(object sender, System.EventArgs e)
        {
            QueryBuilder.Filter filter = DataItem as QueryBuilder.Filter;
            txtFrom.Text = filter.FilterFrom;
            txtTo.Text = filter.FilterTo;
            switch (filter.Node.FType)
            {
                case "N":
                case "N1":
                case "N2":
                case "N3":
                case "N4":
                case "SPN":
                    txtFrom.Visible = txtTo.Visible = false;
                    dpFrom.Visible = dpTo.Visible = false;
                    numFrom.Text = filter.ValueFrom;
                    numTo.Text = filter.ValueTo;
                    break;
                case "SDN":
                    numFrom.Visible = numTo.Visible = false;
                    txtFrom.Visible = txtTo.Visible = false;
                    if (filter.ValueFrom != "")
                        if (filter.ValueFrom == "C")
                            dpFrom.SelectedDate = DateTime.Today;
                        else
                        dpTo.SelectedDate = BUS.CommonControl.ConvertIntToDate(Convert.ToInt32(filter.ValueTo));
                    if (filter.ValueTo != "")
                        if (filter.ValueTo == "C")
                            dpTo.SelectedDate = DateTime.Today;
                        else
                            dpTo.SelectedDate = BUS.CommonControl.ConvertIntToDate(Convert.ToInt32(filter.ValueTo));
                    break;
                default:
                    numFrom.Visible = numTo.Visible = false;
                    dpFrom.Visible = dpTo.Visible = false;
                    txtFrom.Text = filter.ValueFrom;
                    txtTo.Text = filter.ValueTo;
                    break;
            }
            //    ArrayList tocs = new ArrayList(new string[] { "Dr.", "Mr.", "Mrs.", "Ms." });

            //    ddlTOC.DataSource = tocs;
            //    ddlTOC.DataBind();

            //    object tocValue = DataBinder.Eval(DataItem, "TitleOfCourtesy");

            //    if (tocValue == DBNull.Value)
            //    {
            //        tocValue = "Mrs.";
            //    }
            //    ddlTOC.SelectedIndex = tocs.IndexOf((string)tocValue);
            //    ddlTOC.DataSource = null;
        }




    }
}